package jsj.mynet;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class MyUdpReceiveDemo {

	public static void main(String[] args) throws Exception {
		DatagramSocket ds = new DatagramSocket(10086);
		byte[] buf = new byte[1024];
		DatagramPacket dp = new DatagramPacket(buf, buf.length);
		ds.receive(dp);
		
		String ip = dp.getAddress().getHostAddress();
		int port = dp.getPort();
		byte[] buf2 = dp.getData();
		String text = new String(buf2,0,dp.getLength());
		System.out.println(ip+":"+port+":"+text);
		
		ds.close();

	}

}
